home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Magazine / Morphos / GCC / os-includeppc / powerpc / powerpc.h < prev    next >
C/C++ Source or Header  |  1998-04-07  |  10KB  |  289 lines

  1. #ifndef POWERPC_POWERPC_H
  2. #define POWERPC_POWERPC_H
  3.  
  4. /*
  5. **  $VER: powerpc.h 2.0 (15.03.98)
  6. **  WarpOS Release 14.1
  7. **
  8. **  '(C) Copyright 1998 Haage & Partner Computer GmbH'
  9. **       All Rights Reserved
  10. */
  11.  
  12.  
  13. #ifndef EXEC_TYPES_H
  14. #include <exec/types.h>
  15. #endif
  16.  
  17. #ifndef EXEC_LIBRARIES_H
  18. #include <exec/libraries.h>
  19. #endif
  20.  
  21. #define POWERPCNAME "powerpc.library"
  22.  
  23. struct PPCBase {
  24.         struct Library PPC_LibNode;
  25.         APTR PPC_SysLib;
  26.         APTR PPC_DosLib;
  27.         APTR PPC_SegList;
  28.         APTR PPC_NearBase;
  29.         UBYTE PPC_Flags;
  30.         UBYTE PPC_DosVer;
  31. };
  32.  
  33. /* tagitem values for GetHALInfo (V14+) */
  34.  
  35. #define HINFO_TAGS            (TAG_USER+0x103000)
  36. #define HINFO_ALEXC_HIGH      (HINFO_TAGS+0)     /* High word of emulated
  37.                                                     alignment exceptions */
  38. #define HINFO_ALEXC_LOW       (HINFO_TAGS+1)     /* Low word of ... */
  39.  
  40. /* tagitem values for SetScheduling (V14+) */
  41.  
  42. #define SCHED_TAGS            (TAG_USER+0x104000)
  43. #define SCHED_REACTION        (SCHED_TAGS+0)     /* reaction of low activity tasks */
  44.  
  45. /* tagitem values for GetInfo */
  46.  
  47. #define GETINFO_TAGS    (TAG_USER+0x102000)
  48. #define GETINFO_CPU     (GETINFO_TAGS+0)   /* CPU type (see below) */
  49. #define GETINFO_PVR     (GETINFO_TAGS+1)   /* PVR type (see below) */
  50. #define GETINFO_ICACHE  (GETINFO_TAGS+2)   /* Instruction cache state */
  51. #define GETINFO_DCACHE  (GETINFO_TAGS+3)   /* Data cache state */
  52. #define GETINFO_PAGETABLE (GETINFO_TAGS+4)   /* Page table location */
  53. #define GETINFO_TABLESIZE (GETINFO_TAGS+5)   /* Page table size */
  54. #define GETINFO_BUSCLOCK (GETINFO_TAGS+6)   /* PPC bus clock */
  55. #define GETINFO_CPUCLOCK (GETINFO_TAGS+7)   /* PPC CPU clock */
  56. #define GETINFO_CPULOAD (GETINFO_TAGS+8)   /* Total CPU usage */
  57. #define GETINFO_SYSTEMLOAD (GETINFO_TAGS+9) /* Total system usage */
  58.  
  59.  
  60. /* PPCINFO_ICACHE / PPCINFO_DCACHE */
  61.  
  62. #define CACHEB_ON_UNLOCKED      0
  63. #define CACHEB_ON_LOCKED        1
  64. #define CACHEB_OFF_UNLOCKED     2
  65. #define CACHEB_OFF_LOCKED       3
  66.  
  67. #define CACHEF_ON_UNLOCKED      (1L<<0)
  68. #define CACHEF_ON_LOCKED        (1L<<1)
  69. #define CACHEF_OFF_UNLOCKED     (1L<<2)
  70. #define CACHEF_OFF_LOCKED       (1L<<3)
  71.  
  72.  
  73. #define CPUB_603   4
  74. #define CPUB_603E  8
  75. #define CPUB_604   12
  76. #define CPUB_604E  16
  77. #define CPUB_620   20
  78.  
  79. #define CPUF_603  (1L<<4)
  80. #define CPUF_603E (1L<<8)
  81. #define CPUF_604  (1L<<12)
  82. #define CPUF_604E (1L<<16)
  83. #define CPUF_620  (1L<<20)
  84.  
  85. struct PPCArgs {
  86.         APTR  PP_Code;          /* Code Entry / Basevariable (OS Callback) */
  87.         LONG  PP_Offset;        /* Offset into Library-Jumptable (OS Callback) */
  88.         ULONG PP_Flags;         /* see below */
  89.         APTR  PP_Stack;         /* Pointer to first argument to be copied or NULL */
  90.         ULONG PP_StackSize;     /* Size of stack area to be copied or 0 */
  91.         ULONG PP_Regs[15];      /* Registervalues to be transferred */
  92.         DOUBLE PP_FRegs[8];     /* FPU Registervalues to be transferred */
  93. };
  94.  
  95. /* PP_Flags */
  96.  
  97. #define PPF_ASYNC   (1L<<0) // call PPC/68K asynchron
  98.  
  99. /* status returned by RunPPC, WaitForPPC, Run68K and WaitFor68K */
  100.  
  101. #define PPERR_SUCCESS  0 // success
  102. #define PPERR_ASYNCERR 1 // synchron call after asynchron call
  103. #define PPERR_WAITERR  2 // WaitFor[PPC/68K] after synchron call
  104.  
  105. /* Offsets into the RegisterArrays.for 68K Callbacks */
  106. #define PPREG_D0 0
  107. #define PPREG_D1 1
  108. #define PPREG_D2 2
  109. #define PPREG_D3 3
  110. #define PPREG_D4 4
  111. #define PPREG_D5 5
  112. #define PPREG_D6 6
  113. #define PPREG_D7 7
  114.  
  115. #define PPREG_A0 8
  116. #define PPREG_A1 9
  117. #define PPREG_A2 10
  118. #define PPREG_A3 11
  119. #define PPREG_A4 12
  120. #define PPREG_A5 13
  121. #define PPREG_A6 14
  122.  
  123. #define PPREG_FP0 0
  124. #define PPREG_FP1 1
  125. #define PPREG_FP2 2
  126. #define PPREG_FP3 3
  127. #define PPREG_FP4 4
  128. #define PPREG_FP5 5
  129. #define PPREG_FP6 6
  130. #define PPREG_FP7 7
  131.  
  132. #ifndef POWERPCLIB_V7 /* use max. version 7 of powerpc.library -> */
  133.                       /* ppc.library can be used instead of WarpKernal */
  134.                       /* V7 is recommended for "simple" applications */
  135.  
  136. /* Cache flags (required by SetCache) */
  137.  
  138. #define CACHE_DCACHEOFF    1
  139. #define CACHE_DCACHEON     2
  140. #define CACHE_DCACHELOCK   3
  141. #define CACHE_DCACHEUNLOCK 4
  142. #define CACHE_DCACHEFLUSH  5
  143. #define CACHE_ICACHEOFF    6
  144. #define CACHE_ICACHEON     7
  145. #define CACHE_ICACHELOCK   8
  146. #define CACHE_ICACHEUNLOCK 9
  147. #define CACHE_ICACHEINV    10
  148.  
  149. /* Hardware flags (required by SetHardware) */
  150.  
  151. #define HW_TRACEON              1             /* enable singlestep mode */
  152. #define HW_TRACEOFF             2             /* disable singlestep mode */
  153. #define HW_BRANCHTRACEON        3             /* enable branch trace mode */
  154. #define HW_BRANCHTRACEOFF       4             /* disable branch trace mode */
  155. #define HW_FPEXCON              5             /* enable FP exceptions */
  156. #define HW_FPEXCOFF             6             /* disable FP exceptions */
  157. #define HW_SETIBREAK            7             /* set instruction breakpoint */
  158. #define HW_CLEARIBREAK          8             /* clear instruction breakpoint */
  159. #define HW_SETDBREAK            9             /* set data breakpoint (604[E] only) */
  160. #define HW_CLEARDBREAK          10            /* clear data breakpoint (604[E] only) */
  161.  
  162. /* return values of SetHardware */
  163.  
  164. #define HW_AVAILABLE      -1              /* feature available */
  165. #define HW_NOTAVAILABLE    0              /* feature not available */
  166.  
  167. /* return values of GetPPCState */
  168.  
  169. #define PPCSTATEB_POWERSAVE     0              /* PPC is in power save mode */
  170. #define PPCSTATEB_APPACTIVE     1              /* PPC application tasks are active */
  171. #define PPCSTATEB_APPRUNNING    2              /* PPC application task is running */
  172.  
  173. #define PPCSTATEF_POWERSAVE     (1L<<0)
  174. #define PPCSTATEF_APPACTIVE     (1L<<1)
  175. #define PPCSTATEF_APPRUNNING    (1L<<2)
  176.  
  177. /* FP flags (required by ModifyFPExc) */
  178.  
  179. #define FPB_EN_OVERFLOW    0        /* enable overflow exception */
  180. #define FPB_EN_UNDERFLOW   1        /* enable underflow exception */
  181. #define FPB_EN_ZERODIVIDE  2        /* enable zerodivide exception */
  182. #define FPB_EN_INEXACT     3        /* enable inexact op. exception */
  183. #define FPB_EN_INVALID     4        /* enable invalid op. exception */
  184. #define FPB_DIS_OVERFLOW   5        /* disable overflow exception */
  185. #define FPB_DIS_UNDERFLOW  6        /* disable underflow exception */
  186. #define FPB_DIS_ZERODIVIDE 7        /* disable zerodivide exception */
  187. #define FPB_DIS_INEXACT    8        /* disable inexact op. exception */
  188. #define FPB_DIS_INVALID    9        /* disable invalid op. exception */
  189.  
  190. #define FPF_EN_OVERFLOW    (1L<<0)
  191. #define FPF_EN_UNDERFLOW   (1L<<1)
  192. #define FPF_EN_ZERODIVIDE  (1L<<2)
  193. #define FPF_EN_INEXACT     (1L<<3)
  194. #define FPF_EN_INVALID     (1L<<4)
  195. #define FPF_DIS_OVERFLOW   (1L<<5)
  196. #define FPF_DIS_UNDERFLOW  (1L<<6)
  197. #define FPF_DIS_ZERODIVIDE (1L<<7)
  198. #define FPF_DIS_INEXACT    (1L<<8)
  199. #define FPF_DIS_INVALID    (1L<<9)
  200.  
  201. #define FPF_ENABLEALL      $0000001f   /* enable all FP exceptions */
  202. #define FPF_DISABLEALL     $000003e0   /* disable all FP exceptions */
  203.  
  204. /* tags passed to SetExcHandler (exception handler attributes) */
  205.  
  206. #define EXCATTR_TAGS    (TAG_USER+0x101000)
  207. #define EXCATTR_CODE    (EXCATTR_TAGS+0)   /* exception code (required) */
  208. #define EXCATTR_DATA    (EXCATTR_TAGS+1)   /* exception data */
  209. #define EXCATTR_TASK    (EXCATTR_TAGS+2)   /* ppc task address (or NULL) */
  210. #define EXCATTR_EXCID   (EXCATTR_TAGS+3)   /* exception ID */
  211. #define EXCATTR_FLAGS   (EXCATTR_TAGS+4)   /* see below */
  212. #define EXCATTR_NAME    (EXCATTR_TAGS+5)   /* identification name */
  213. #define EXCATTR_PRI     (EXCATTR_TAGS+6)   /* handler priority */
  214.  
  215. /* EXCATTR_FLAGS (either EXC_GLOBAL or EXC_LOCAL, resp. */
  216. /*                EXC_SMALLCONTEXT or EXC_LARGECONTEXT must be */
  217. /*                specified) */
  218.  
  219. #define EXCB_GLOBAL       0        /* global handler */
  220. #define EXCB_LOCAL        1        /* local handler */
  221. #define EXCB_SMALLCONTEXT 2        /* small context structure */
  222. #define EXCB_LARGECONTEXT 3        /* large context structure */
  223. #define EXCB_ACTIVE       4        /* private */
  224.  
  225. #define EXCF_GLOBAL       (1L<<0)
  226. #define EXCF_LOCAL        (1L<<1)
  227. #define EXCF_SMALLCONTEXT (1L<<2)
  228. #define EXCF_LARGECONTEXT (1L<<3)
  229. #define EXCF_ACTIVE       (1L<<4)
  230.  
  231. /* EXCATTR_EXCID (Exception ID) */
  232.  
  233. #define EXCB_MCHECK   2              /* machine check exception */
  234. #define EXCB_DACCESS  3              /* data access exception */
  235. #define EXCB_IACCESS  4              /* instruction access exception */
  236. #define EXCB_ALIGN    6              /* alignment exception */
  237. #define EXCB_PROGRAM  7              /* program exception */
  238. #define EXCB_FPUN     8              /* FP unavailable exception */
  239. #define EXCB_TRACE    13             /* trace exception */
  240. #define EXCB_PERFMON  15             /* performance monitor exception */
  241. #define EXCB_IABR     19             /* IA breakpoint exception */
  242.  
  243. #define EXCF_MCHECK   (1L<<2)
  244. #define EXCF_DACCESS  (1L<<3)
  245. #define EXCF_IACCESS  (1L<<4)
  246. #define EXCF_ALIGN    (1L<<6)
  247. #define EXCF_PROGRAM  (1L<<7)
  248. #define EXCF_FPUN     (1L<<8)
  249. #define EXCF_TRACE    (1L<<13)
  250. #define EXCF_PERFMON  (1L<<15)
  251. #define EXCF_IABR     (1L<<19)
  252.  
  253. /* large exception context structure (if EXCATTR_LARGECONTEXT was set) */
  254.  
  255. struct EXCContext {
  256.         ULONG ec_ExcID;       /* exception ID (see above) */
  257.         union {
  258.                 ULONG  ec_SRR0;    /* process' program counter */
  259.                 APTR   ec_PC;
  260.         } ec_UPC;
  261.         ULONG ec_SRR1;        /* process' context */
  262.         ULONG ec_DAR;         /* DAR register */
  263.         ULONG ec_DSISR;       /* DSISR register */
  264.         ULONG ec_CR;          /* condition code register */
  265.         ULONG ec_CTR;         /* count register */
  266.         ULONG ec_LR;          /* link register */
  267.         ULONG ec_XER;         /* integer exception register */
  268.         ULONG ec_FPSCR;       /* FP status register */
  269.         ULONG ec_GPR[32];     /* r0 - r31 */
  270.         DOUBLE ec_FPR[32];    /* f0 - f31 */
  271. }; /* don't depend on sizeof(EXCContext) */
  272.  
  273. /* small exception context structure (if EXCATTR_SMALLCONTEXT was set) */
  274.  
  275. struct XContext {
  276.         ULONG xco_ExcID;      /* exception ID (see above) */
  277.         ULONG xco_R3;         /* register r3 */
  278. }; /* don't depend on sizeof(XCOSize) */
  279.  
  280. /* return values for exception handlers */
  281.  
  282. #define EXCRETURN_NORMAL 0       /* allow the next exc handlers to complete */
  283. #define EXCRETURN_ABORT  1       /* exception is immediately leaved, all */
  284.                                  /* other exception handlers are ignored */
  285.  
  286. #endif /* POWERPCLIB_V7 */
  287.  
  288. #endif
  289.